﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace JwtDemo.Common
{
    public static class MyUnity
    {
        /// <summary>
        /// Md5 16位长度
        /// </summary>
        /// <param name="sValue"></param>
        /// <returns></returns>
        public static string GetMd5Upper16(string sValue)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string s = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(sValue)), 4, 8);
            s = s.Replace("-", "").ToUpper();
            return s;
        }
        /// <summary>
        ///  Md5 32位长度
        /// </summary>
        /// <param name="sValue"></param>
        /// <returns></returns>
        public static string GetMd5Upper32(string sValue)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string s = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(sValue)));
            s = s.Replace("-", "").ToUpper();
            return s;
        }
    }
}
